<!DOCTYPE html PUBLIC "-//W2C//DTD XHTML 2.2//EN" "xhtml22.dtd">
<html debug="true"><head>
<title>图表统计</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="highcharts/jquery.js"></script>
<script src="highcharts/highcharts.js"></script>
<script type="text/javascript">
var str=location.href;
var num=str.indexOf("?");
var str1=str.substr(num+1);
var username=str1.split("=")[1];
var persons = new Array();
var per;
	

	
(function($){ // encapsulate jQuery
var chart;

$(document).ready(function() {
	
	function getXmlHttpObject(){
		var xmlHttpRequest;
		if(window.ActiveXObject){
		}else{
			xmlHttpRequest=new XMLHttpRequest();
		}
		return xmlHttpRequest;
	}
	myXmlHttpRequest=getXmlHttpObject();
	if(myXmlHttpRequest){
		var url="http://localhost:8080/StuScoreSystem/Admin?method=lookoutScores&stuclass=14级02班&major=软件工程";
		myXmlHttpRequest.open("get",url,true);
		myXmlHttpRequest.onreadystatechange=progress;
		myXmlHttpRequest.send(null);
	}
	else{
		window.alert("error");
	}
	function progress(){
		if(myXmlHttpRequest.readyState==4){
			var json=myXmlHttpRequest.responseText;
			var json_obj=eval("("+json+")");
			var meta=json_obj.meta;
			if(meta.state=="success"){
				per=json_obj.data;
				for(var i=0;i<per.length;i++){
					persons[i]=new Object();
					persons[i].name=per[i].stuname;
					persons[i].data= new Array();
					persons[i].data=[per[i].java,per[i].Cpp,per[i].python,per[i].CSharp];
					var temp=["90","80","98","69"];
					var tmpdata=[90,80,70,95];
					console.log(tmpdata);
					console.log(temp);
				}
			}
			else{
				window.alert(meta.message);
			}
		}
		chart = new Highcharts.Chart({
				chart: {
					renderTo: 'container',
					type: 'line',
					marginRight: 220,
					marginBottom: 25
				},
				title: {
					text: '学生各科成绩折线图',
					x: -20 //center
				},
				subtitle: {
					text: '',
					x: -20
				},
				xAxis: {
			//categories: ['02年', '02年', '02年', '04年', '05年', '06年',
				//'07年', '08年', '09年', '20年', '22年', '22年']
					categories: ['Java', 'Cpp', 'python', 'CSharp']
				},
				yAxis: {
					title: {
					text: '数据'
				},
					plotLines: [{
						value: 0,
						width: 2,
						color: '#808080'
					}]
				},
				tooltip: {
					formatter: function() {
						return '<b>'+ this.series.name +'</b><br/><br/>'+
						this.x +': '+ this.y +'分';
					}
				},
				legend: {
					layout: 'vertical',
					align: 'right',
					verticalAlign: 'top',
					x: -20,
					y: 200,
					borderWidth: 0
				},
				series: persons
			});
		
		//for(var i=0;i<per.length;i++)
			//window.alert(chart.series[i].data);
		console.log(persons[1].data);
	}

});
})(jQuery);
</script>
<body>
	<div id="sub" style="margin: 0 2em">
		<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
	</div>
</div>
</body></html>